﻿
#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

#endregion

namespace MarketPulse.BusinessLogic.Private.StateMachine
{
    internal interface IAssignmentState
    {

        /// <summary>
        /// Method used to assign the Assignment to a specific user based on the user guid value supplied
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        /// <param name="userGuid">The Guid of the user to assign this Assignment to</param>
        /// <param name="plannedDateTime">The date the Assignment is planned to take place</param>
        bool Assign(IAssignmentStateContext context, bool tryTransition, Guid userGuid, DateTime plannedDateTime);

        ///// <summary>
        ///// Method used to unassign the Assignment
        ///// </summary> 
        ///// <param name="context">The current state machine context</param>
        ///// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        ///// <param name="payment">Enumeration vairable used to deterine whether payment should be honoured</param>
        //bool Unassign(IAssignmentStateContext context, bool tryTransition, Assignment.PaymentStatus payment);

        /// <summary>
        /// Method used to release the Assignment and make it ready to be assigned
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool Release(IAssignmentStateContext context, bool tryTransition);
 
        /// <summary>
        /// Method used to save the information for this Assignment captured as part of the data entry process
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool StartDataEntry(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to save the information for this Assignment captured as part of the data entry process
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        /// <param name="responses">The XML response set to attach to the survey instance for the Assignment</param>
        bool DataEnter(IAssignmentStateContext context, bool tryTransition, XElement responses);

        /// <summary>
        /// Method used to complete the data entry process for this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool CompleteDataEntry(IAssignmentStateContext context, bool tryTransition);

        #region QA Methods

        /// <summary>
        /// Method used to begin the QA process for this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAStartDataEntry(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to enter data during the QA process for this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QADataEnter(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to approve the QA of the responses gathered as part of this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAApprove(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to fail the QA of the responses gathered as part of this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAFail(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to put the QA process on hold whilst other aspects of the Assignment are adressed 
        /// (i.e. query from the branch, clarification of an answer by the shopper etc...)
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAPutOnHold(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to reopen the QA process for this Assignment
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAReopen(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to mark this Assignment as Ready to Transfer
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool MarkReadyForTransfer(IAssignmentStateContext context, bool tryTransition);

        /// <summary>
        /// Method used to create a new version of this visit for revisiting
        /// </summary>
        /// <param name="context">The current state machine context</param>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool Revisit(IAssignmentStateContext context, bool tryTransition);

        #endregion

        /// <summary>Property to allow read-only access to the database defined Guid for the current visit state</summary>
        Guid StateGuid { get; }

        /// <summary>
        /// Property to set and get a flag to indicate if an exception should be thrown when
        /// an invalid transition is attempted.
        /// </summary>
        bool ThrowIfInvalid { get; set; }

    }
}
